package com.igame.Controller;


import com.igame.Service.CommentService;
import com.igame.common.Result;
import com.igame.entity.Comment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin //忽视跨域问题
@RestController
@RequestMapping("/comment")
@Slf4j
public class CommentController {

    @Autowired
    CommentService commentService;

    @PostMapping("/getComment")
    public Result<List<Comment>> getComment(@RequestBody Integer id){
        return commentService.getComment(id);
    }

    @PostMapping("/submitComment")
    public Result insert(@RequestBody Comment comment){
       return commentService.insertComment(comment);
    }

    @PostMapping("/getReply")
    public Result<List<Comment>> getReply(@RequestBody String userName){
        return commentService.getReply(userName);
    }
}
